<template>
  <div>
    <div class="head">
      <div class="box">
        <div class="box-left" @click="homeChang">
          <img src="../images/lucency-logo.png" alt />
        </div>
        <div class="box-centent">主体信息修改</div>
        <div class="box-right">
          <div class="box-right-hint" @click="personalData">
            <img src="../images/hint.png" alt />
            <div class="box-right-hint-num" v-if="msgTotal>0">{{msgTotal>9? '···':msgTotal }}</div>
          </div>
          <p @click="personalData">{{nickname}}</p>
          <div class="box-right-img">
            <img @click="personalData" :src="avatar" alt height="100%"/>
          </div>
          
        </div>
      </div>
    </div>
    <keep-alive include>
      <business_modify v-if="stepNum===1" ref="business_modify" @handleChange="handleChange"></business_modify>
    </keep-alive>
    <keep-alive include>
      <Information
        v-if="stepNum===2"
        @lastStep="lastStep"
        @handleChange="handleChange"
      ></Information>
    </keep-alive>
    <Payment @lastStep="lastStep"  @handleChange="handleChange" v-if="stepNum===3"></Payment>
    <Accomplish v-if="stepNum===4"></Accomplish>
  </div>
</template>

<script>
import business_modify from "../views/ApplyFor/business_modify";
import Information from "../views/process/information";
import Payment from "../views/process/payment";
import Accomplish from "../views/process/accomplish";
import { comment_total } from "@/utils/api";
export default {
  name: "applyFor",
  components: {
    business_modify,
    Information,
    Payment,
    Accomplish
  },
  data() {
    return {
      stepNum: 1,
      avatar: "",
      nickname: "",
      msgTotal: "",
      edit:''
    };
  },
  created() {
    //获取留言条数
    if(localStorage.getItem("token")){
      comment_total({}, res => {
        localStorage.setItem('msgTotal', res.data)
      })
    }
    this.avatar = localStorage.getItem("avatar");
    this.nickname = localStorage.getItem("nickname");
    this.msgTotal = localStorage.getItem("msgTotal");
    console.log("头部", this.$route.params.unpaid);
    var orderNo = this.$route.params.unpaid;
    if (orderNo) {
      localStorage.setItem("orderNo", orderNo);
      this.stepNum = 3;
    }
   this.edit=this.$route.query.edit
   if (this.edit) {
      this.stepNum = 2;
      localStorage.setItem('edit',this.edit)
    }
  },
  updated(){
    if(this.stepNum==1){
      // 调用子组件
      this.$refs.business_modify.initInfo()
    }
 
  },
  methods: {
    stepChange(val) {
      if (val > this.stepNum) {
        return false;
      } else {
        this.stepNum = val;
      }
    },

    // 子组件调用
    handleChange() {
      this.stepNum++;
      console.log("子组件调用");
    },
    lastStep() {
      this.stepNum--;
    },
    // 个人中心跳转
    personalData() {
      this.$router.push({ name: "datum" });
    },
    homeChang() {
      this.$router.push({ name: "home" });
    }
  }
};
</script>

<style scoped lang="scss">
.head {
  width: 100%;
  height: 120px;
  background-color: #3a7bd8;
}
.box {
  max-width: 1920px;
  min-width: 1440px;
  // width: 100%;
  height: 120px;
  margin: auto;
  display: flex;
  &-left {
    padding-left: 50px;
    display: flex;
    align-items: center;
    vertical-align: middle;
    width: 29.4%;
    height: 120px;
    cursor: pointer;
    > img {
      width: 100%;
    }
  }
  &-centent {
    width: 20%;
    margin-left: 1.6%;
    padding-left: 1.6%;
    border-left: 1px solid #ffffff;
    height: 60px;
    margin-top: 30px;
    display: flex;
    align-items: center;
    font-size: 28px;
    font-weight: bold;
    color: #ffffff;
    letter-spacing: 3px;
  }
  &-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    // outline: 2px solid red;
    padding-right: 60px;
    &-hint {
      // width:34px;
      //     height: 40px;
      position: relative;
      margin-right: 20px;
      cursor: pointer;
      > img {
        width: 21px;
        height: 23px;
      }
      &-num {
        width: 23px;
        height: 23px;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: red;
        position: absolute;
        border-radius: 50%;
        font-size: 12px;
        font-weight: 500;
        color: #ffffff;
        top: -8px;
        right: -13px;
        border: 3px solid #3c7dd8;
      }
    }

    > p {
      font-size: 18px;
      font-weight: 400;
      color: #ffffff;
      cursor: pointer;
    }


    &-img {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      cursor: pointer;
      margin-left: 20px;
      cursor: pointer;
      // margin-right: 60px;
      // outline: 2px solid red;
      overflow: hidden;
    }
  }
}

.top {
  width: 100%;
  height: 160px;
  // box-shadow: 1px 1px 18px 0px rgba(207, 2, 37, 0.11);
  background-color: #ffffff;
  border-bottom: 1px solid rgba(87, 87, 87, 0.1);
  &-box {
    width: 73%;
    min-width: 1022px;
    height: 160px;
    margin: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    &-start {
      width: 307px;
      height: 61px;
      background: url("../images/step-start.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #999999;
      cursor: pointer;
    }
    &-item {
      width: 307px;
      height: 61px;
      background: url("../images/step.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #999999;
      cursor: pointer;

      &-tail {
        width: 307px;
        height: 61px;
        background: url("../images/step-tail.png");
        background-size: 100% 100%;
        background-position: center;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 18px;
        font-weight: 400;
        color: #999999;
        cursor: pointer;
      }
    }
    &-middle {
      width: 307px;
      height: 61px;
      background: url("../images/step-middle.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #ffffff;
      cursor: pointer;
    }
    &-action {
      width: 307px;
      height: 61px;
      background: url("../images/step-action.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #ffffff;
      cursor: pointer;
    }
    &-selected {
      width: 307px;
      height: 61px;
      background: url("../images/step-tail-action.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #ffffff;
      cursor: pointer;
    }
  }
}
</style>
